package cst.a211myx.fragmenttest.fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import cst.a211myx.fragmenttest.R;
import cst.a211myx.fragmenttest.adapter.MyAdapter;
import cst.a211myx.fragmenttest.bean.ArticleBean;
import cst.a211myx.fragmenttest.iface.ArticleListener;
import cst.a211myx.fragmenttest.model.ArticleModel;

/**
 * A simple {@link Fragment} subclass.
 */
public class WeixinFragment extends Fragment {
    private View view=null;
    private Context context;
    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private MyAdapter myAdapter;
    private List<ArticleBean> list=null;
    ArticleListener articleListener=new ArticleListener() {
        @Override
        public void onResponse(List<ArticleBean> blist) {
            list=blist;
            myAdapter.setList(list);
        }
        @Override
        public void onFail(String msg) {
            Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
        }
    };
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        context=getActivity();
        view=inflater.inflate(R.layout.wfragment,container,false);
        recyclerView=(RecyclerView)view.findViewById(R.id.recycleView);
        layoutManager=new LinearLayoutManager(context);
        recyclerView.setLayoutManager(layoutManager);
        myAdapter=new MyAdapter(context);
        myAdapter.setList(list);
        recyclerView.setAdapter(myAdapter);

        ArticleModel articleModel=new ArticleModel();
        articleModel.getResultLIist("article",2,"k17vmm42ui9al6clh0lo3de2t7",articleListener);
        Toast.makeText(context, "微信：", Toast.LENGTH_SHORT).show();
        return view;
    }

}
